package com.enumdemo.kind.demo2;

import java.util.Random;

import com.enumdemo.kind.demo1.Food;

/**
 * 枚举的枚举
 * 
 * @author Administrator
 *
 */
public enum Course {

	APPETIZER(Food.Appetizer.class), MAINCOURSE(Food.MainCourse.class), DESSERT(
			Food.Dessert.class), COFFEE(Food.Coffee.class);

	private Food[] values;

	// 通过getEnumConstants()获取某个Food子类的所有enum实例
	private Course(Class<? extends Food> kind) {
		values = kind.getEnumConstants();
	}

	Random rand = new Random(47);

	public Food randomSelectin() {
		return values[rand.nextInt(4)];
	}

}
